home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKitArchive.mbox / mbox / 000066_d89cb@efd.lth.se_Tue Oct 12 06:15 MDT 1993.msg < prev    next >
Internet Message Format  |  1994-10-30  |  6KB

  1. Received: from yvax.byu.edu by maine.et.byu.edu; Tue, 12 Oct 93 06:15:13 -0600
  2. Return-Path: <d89cb@efd.lth.se>
  3. Received: from DIRECTORY-DAEMON by yvax.byu.edu (PMDF V4.2-13 #4169) id
  4.  <01H40JT2RWTS94M1L4@yvax.byu.edu>; Tue, 12 Oct 1993 06:13:13 MDT
  5. Received: from alaska.et.byu.edu by yvax.byu.edu (PMDF V4.2-13 #4169) id
  6.  <01H40JSYUCJK9BVPFU@yvax.byu.edu>; Tue, 12 Oct 1993 06:13:07 MDT
  7. Received: from yvax.byu.edu by alaska.et.byu.edu; Tue, 12 Oct 93 06:14:49 -0600
  8. Received: from DIRECTORY-DAEMON by yvax.byu.edu (PMDF V4.2-13 #4169) id
  9.  <01H40JSM1QKW94M1L4@yvax.byu.edu>; Tue, 12 Oct 1993 06:12:50 MDT
  10. Received: from efd.lth.se (oddput.efd.lth.se) by yvax.byu.edu (PMDF V4.2-13
  11.  #4169) id <01H40JSHLVJK9BVOND@yvax.byu.edu>; Tue, 12 Oct 1993 06:12:44 MDT
  12. Received: from neptunus-6.efd.lth.se by efd.lth.se with smtp (Smail3.1.28.1 #1)
  13.  id m0omib7-0002VeC; Tue, 12 Oct 93 13:13 MET
  14. Received: by neptunus-6.efd.lth.se (Smail3.1.28.1 #3) id m0omiae-0000RMC; Tue,
  15.  12 Oct 93 13:12 MET
  16. Date: Tue, 12 Oct 1993 13:12 +0100 (MET)
  17. From: d89cb@efd.lth.se (Christian Brunschen)
  18. Subject: Am I insane ?
  19. To: misckit@byu.edu
  20. Message-Id: <m0omiae-0000RMC@neptunus-6.efd.lth.se>
  21. X-Mailer: Mail User's Shell (7.2.4 2/2/92)
  22. Content-Transfer-Encoding: 7BIT
  23. Status: RO
  24.  
  25. You know, I've had a really wild idea.  The kind of idea that will be
  26. discribed as either "insane" or "insanely great".
  27.  
  28. Let me give you some background:
  29.  
  30. Our university has recently installed 50 Sun SPARCclassic machines --
  31. the first machines on campus that have actual sound support (no NeXTen
  32. on campus here, alas). We are running, on these machines, Solaris 2.1
  33. -- ie, SunOS 5.2 -- but under vanilla X11R5, using twm as a window
  34. manager.
  35.  
  36. An immediate side effect of sound-aware machines showing up was that
  37. people have started associating sounds with actions in the window
  38. manager: A friend of mine has a gun-shot sound for the window-kill
  39. function. To achieve this, he created a function of his own (winkill)
  40. which plays the sound and kills the window using twm:s f.kill
  41. function. He then replaced all calls to f.kill with calls to his own
  42. winkill.
  43.  
  44. What he did was basically, subclass twm, and override the f.kill
  45. function.
  46.  
  47. This was not difficult in any way. However, I could not do that under
  48. NeXTSTEP with the current set of tools available. Oh, sure, I could
  49. open every .nib file in my entire file system and drop "bang.snd" on
  50. the close button of every window. But this is a non-general way of
  51. doing it and requres much work on my part -- and I have to redo _all_
  52. the work if I want to use another sound, or do something else than
  53. just play a sound.
  54.  
  55. (So, where's the really neat idea? Coming real soon, promise :-)
  56.  
  57. What I would _really_ like to do is replace the Window class, as it is
  58. in the system, with a subclass that I have defined myself. Obviously,
  59. I don't have the source code to most applications, so this approach
  60. doesn't appear very workable. Or is it? Hmmm... Waitasec .. Ah! Bingo!
  61. there it is ... "poseAs"!
  62.  
  63. OK, now we have a way to replace one class by a subclass; There is one
  64. restriction -- we can't add any instance varibales -- but that should
  65. be possible to circumvent if we absolutely _have_ to, so no big deal.
  66.  
  67. We also know how to load classes -- NXBundle is there to help us.
  68.  
  69. So, what we need is simple a way to, automatically at application
  70. startup, do the following:
  71.  
  72. * Check the defaults database for which classes should be replaced,
  73. and which classes should take their places 
  74.  
  75. * Load each replacementclass (an NXBundle, most likely)
  76.  
  77. * Send each replacement class the respective +poseAs: message
  78.  
  79.  
  80. All of this must, of course, be done before we have started using any
  81. of the classes we replace.
  82.  
  83. So, we create a class -- preferrably a subclass of Application -- that
  84. does all of this; we could place it in Application's +initialize
  85. method, so it will be done before (almost) anything else.
  86.  
  87. We use this MiscApplication class instead of Application in our
  88. applications. And now, I can simply create my own subclass of Window
  89. that goes "KaBLAM!" when it is closed, put this class in an NXBundle,
  90. do a dwrite (something like "dwrite GLOBAL replacementClasses
  91. BlamWindow:Window" perhaps) and every application that uses
  92. MiscApplication will automatically use the BlamWindow class instead of
  93. plain old Window -- even in their own subclasses of Window!  (For
  94. details on this, consult documentation -- and please point out any
  95. errors that I have made in my reasoning.)
  96.  
  97. (Why am I not being more detailed? Beacuse I am not sure about the
  98. details! :)
  99.  
  100. What's _really_ neat about this is that it can be made to work for
  101. arbitrary classes -- ie, you could replace Object with a version that
  102. prints debugging info, or something. (Of course, in most applications
  103. this isn't really something we want J. Random User to do, so some kind
  104. of security system (like, "don't replace any classes that are above
  105. View in the class hierarchy") should be implemented as well.) This is
  106. en _extremely_ general and powerful way of customizing application
  107. behaviour to suit your needs -- not only can you have a window that
  108. goes BLAM everytime you close it, you can also (for instance) have a
  109. scroller give you audio feedback as to its position (shouldn't be too
  110. hard to do, should it? Let it make a sound with a frequency (or
  111. volume) that is calculated from where the scroller is ... and you
  112. automatically get it in _every app_ that uses the MiscApplication
  113. object, not just apps where the implementor thought this would be a
  114. cool idea! :-) !!
  115.  
  116. How does this help me with existing applications? It doesn't. But
  117. since this idea is so damn general, maybe we could convince people to
  118. start using it in their applications.
  119.  
  120. Any comments ? Is this insane, or insanely great ?
  121.  
  122. Best regards
  123.  
  124. // Christian Brunschen
  125.  
  126. | Christian Brunschen, Husmansv. 26, S-227 38 Lund, Sweden             |
  127. | voice/fax/data +46 (0)46 139345, email d89cb@efd.lth.se              |
  128. | PGP 2.2 Public Key available on request. | ObCelebrityQuote:         |
  129. | "Oh, foo."                                                           |
  130. |     - Andrew R. Koenig (ark@research.att.com) after dropping a piece |
  131. |       of chalk during a lecture on C++ in Lund, Sweden, April 1993   |